<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

function smarty_function_number_format($params, &$smarty)
{
  $num    = isset($params['num'])    ? $params['num']    : '';

  $decimals = 2;
  $dec_point = '.';
  $thousands_sep = ',';
  $string = str_replace(",", "", $num);
  $value = doubleval($string);
  if ($value > 0){
    return number_format(doubleval($string), intval($decimals), $dec_point, $thousands_sep);
  }else{
    return $string;
  }
}
